package com.hdl.servlet.order;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.hdl.R;
import com.hdl.service.MallOrderService;
import com.hdl.service.impl.MallOrderServiceImpl;

@WebServlet("/admin-order-update.let")
public class OrderUpdateServlet extends HttpServlet{

	Logger log = LoggerFactory.getLogger(this.getClass());
	private MallOrderService service = new MallOrderServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		service.updataStatus(req.getParameter("orderId"), Integer.valueOf(req.getParameter("status")));
		log.debug(req.getParameter("orderId"));
		Object data = R.ok("修改成功");
		req.setAttribute("data",data );
		ObjectMapper mapper = new ObjectMapper();
		resp.setContentType("application/json;charset=UTF-8");
		mapper.writeValue(resp.getOutputStream(),data );
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
	
}
